package com.yehuishou.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;


import com.yehuishou.dao.Bid_OrderDao;
import com.yehuishou.dao.BidingOrderDao;
import com.yehuishou.dao.SaleOrderDao;
import com.yehuishou.pojo.BidOrder;
import com.yehuishou.service.Bid_OrderService;



@Service
public class Bid_OrderServiceImpl  implements Bid_OrderService{

	 @Resource
	 private SaleOrderDao saleOrderDao;
	
	  @Resource
	  private Bid_OrderDao  bid_OrderDao;
	  
	  @Resource
	  private BidingOrderDao bidingOrderDao;

	@Override
	public void insertBidOrder(BidOrder bi) {
		bid_OrderDao.insertBidOrder(bi);
		
	}

	@Override
	public int deleteBidOrder(Integer id) {
		// TODO Auto-generated method stub
		return bid_OrderDao.deleteBidOrder(id);
	}

	@Override
	public void deleteBidOrders(Integer[] td_s) {
		//删除竞价订单中间表
		
		List<String> bidors = new ArrayList<>();
		
		for(int i=0;i<td_s.length;i++) {
			System.out.println("----"+td_s[i]);
			bidors.add(bid_OrderDao.getBidOrder(td_s[i]).getOid());
		}
		
		bidingOrderDao.deleteOrders(bidors);
		System.out.println(bidors.toArray());
		
		//删除订单
		bid_OrderDao.deleteBidOrders(td_s);
	}
}
